package com.tang.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author tang jun liang
 * @Date 2023-05-25 09:53:21
 */
@Getter
public enum DocumentType {
    /**
     * 单据类型
     */
    YEAR_BUDGET(9001, "年度预算单"),

    ANNUAL_INCOME_AND_EXPENDITURE_BUDGET(9002, "年度收支预算表"),

    INCOME(9003, "收入单"),

    PREPAID(9004, "预付单"),

    INVOICES(9005, "结算单"),

    VOUCHER(9006, "凭证"),

    ACCOUNTING_STATEMENT(9007, "会计报表"),

    FIXED_ASSET(9008, "固定资产"),

    MATERIAL(9009, "物料清单"),

    PROJECT_BUDGET(9010, "项目预算"),

    UNKNOWN(0, "未知")
    ;


    @JsonValue
    @EnumValue
    private final Integer value;

    private final String desc;

    DocumentType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }


    @JsonCreator
    public static DocumentType create(Integer value){
        for (DocumentType item: values()){
            if (item.getValue().equals(value)){
                return item;
            }
        }
        return UNKNOWN;
    }

}
